<?php
/**
 * Created by PhpStorm.
 * User: yuyiwen
 * Date: 2018/10/19
 * Time: 上午10:29
 */
header('Content-type:text/html;charset=utf-8');

$dsn = 'mysql:dbname=yl;host=127.0.0.1';
$usr = 'root';
$pwd = 123456;
$pdo = new PDO($dsn , $usr , $pwd);

$sql = "SET names `utf8`";
$pdo->exec($sql);

$sql = <<<A
SELECT `id` , `username` , `action` 
FROM `ssc_admin_log` 
WHERE
 `username` LIKE ? 
OR 
`action` LIKE ?
A;

$res = $pdo -> prepare($sql); // 成功返回pdostatment对象 ， 失败返回false

$res->execute(["%{$_POST['search']}%" , "%{$_POST['search']}%"]);

if ($res == false)
{
    print_r($pdo -> errorInfo());
}


$info = $res->fetchAll(PDO::FETCH_ASSOC);
//echo '<pre>';
//print_r($info);


echo json_encode($info , JSON_UNESCAPED_UNICODE);
//json_decode();










